<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
	<script src="./pub/axios.min.js"></script>
	<script type="text/javascript">
		var http = "http://124.70.151.37:21113"
		// var http = "192.168.1.121:21113"
		localStorage.setItem("http", http);
		var code;

		function getParam() {
			var url = location.search; //获取url中"?"符后的字串
			if (url.indexOf("?") != -1) {
				var str = url.substr(1);
				strs = str.split("&");
				code = decodeURIComponent(strs[0].replace("code=", ""));
			}
		}
		getParam();
		localStorage.setItem("code", code);
		axios.get(http + '/callBack', {
				params: {
					"code": code,
				}
			})
			.then(function (response) {
				console.log(JSON.stringify(response))

				localStorage.setItem("country", response.data.country);
				localStorage.setItem("userId", response.data.userId);
				localStorage.setItem("nickname", response.data.nickname);
				localStorage.setItem("headimgurl", response.data.headimgurl);
				localStorage.setItem("openid", response.data.openid);
				axios.get(http + '/queryUserById', {
						params: {
							"userId": response.data.userId,
						}
					})
					.then(function (response) {
						console.log(JSON.stringify(response))
						if (!response.data.msg) {
							window.location.href = "./Binding/Binding.html"
						} else {
							localStorage.setItem("phonef", response.data.msg);
							window.location.href = "./Userlist/Userlist.html"
						}
					})
			})
	</script>
</head>

<body>

</body>

</html>